package com.ynr.sheet.service.impl;

import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ynr.common.model.SheetBalance;
import com.ynr.common.model.SheetCash;
import com.ynr.common.model.SheetIncome;
import com.ynr.dao.ISheetDao;
import com.ynr.sheet.service.ISheetService;

@Service
public class SheetServiceImpl implements ISheetService {

	private static final Logger logger = LoggerFactory.getLogger(SheetServiceImpl.class);
	
	@Autowired
	private ISheetDao sheetDao;
	
	@Override
	public Map<String, Object> getSheet(String companyId, String billDate, String sheetType) {
		logger.debug("SheetServiceImpl getSheet params, companyId:{}, billDate:{}, sheetType:{}", companyId, billDate, sheetType);
		Map<String, Object> retMap = new HashMap<>();
		switch(sheetType) {
		case "资产负债表":
			SheetBalance sheetBalance = sheetDao.getSheetBalance(companyId, billDate);
			if(sheetBalance != null) {
				retMap.put("result_is_null", "false");
				retMap.put("type", 1);
				DecimalFormat format = new DecimalFormat("#0.000");
				retMap.put("expiry_date", sheetBalance.getBillDate());
				retMap.put("preparedby", sheetBalance.getPreparedby());
				retMap.put("company_controller", sheetBalance.getCompanyController());
				retMap.put("finance_chief", sheetBalance.getFinanceChief());
				retMap.put("tabulator", sheetBalance.getTabulator());
				retMap.put("create_time", sheetBalance.getCreateTime());
				retMap.put("monetary_resources_ending_balance", format.format(sheetBalance.getMonetaryResourcesEndingBalance() == null ? 0 : sheetBalance.getMonetaryResourcesEndingBalance()));
				retMap.put("monetary_resources_beginning_balance", format.format(sheetBalance.getMonetaryResourcesBeginningBalance() == null ? 0 : sheetBalance.getMonetaryResourcesBeginningBalance()));
				retMap.put("short_term_investments_ending_balance", format.format(sheetBalance.getShortTermInvestmentsEndingBalance() == null ? 0 : sheetBalance.getShortTermInvestmentsEndingBalance()));
				retMap.put("short_term_investments_beginning_balance", format.format(sheetBalance.getShortTermInvestmentsBeginningBalance() == null ? 0 : sheetBalance.getShortTermInvestmentsBeginningBalance()));
				retMap.put("bill_receivable_ending_balance", format.format(sheetBalance.getBillReceivableEndingBalance() == null ? 0 : sheetBalance.getBillReceivableEndingBalance()));
				retMap.put("bill_receivable_beginning_balance", format.format(sheetBalance.getBillReceivableBeginningBalance() == null ? 0 : sheetBalance.getBillReceivableBeginningBalance()));
				retMap.put("accounts_receivable_ending_balance", format.format(sheetBalance.getAccountsReceivableEndingBalance() == null ? 0 : sheetBalance.getAccountsReceivableEndingBalance()));
				retMap.put("accounts_receivable_beginning_balance", format.format(sheetBalance.getAccountsReceivableBeginningBalance() == null ? 0 : sheetBalance.getAccountsReceivableBeginningBalance()));
				retMap.put("prepayment_ending_balance", format.format(sheetBalance.getPrepaymentEndingBalance() == null ? 0 : sheetBalance.getPrepaymentEndingBalance()));
				retMap.put("prepayment_beginning_balance", format.format(sheetBalance.getPrepaymentBeginningBalance() == null ? 0 : sheetBalance.getPrepaymentBeginningBalance()));
				retMap.put("dividends_receivable_ending_balance", format.format(sheetBalance.getDividendsReceivableEndingBalance() == null ? 0 : sheetBalance.getDividendsReceivableEndingBalance()));
				retMap.put("dividends_receivable_beginning_balance", format.format(sheetBalance.getDividendsReceivableBeginningBalance() == null ? 0 : sheetBalance.getDividendsReceivableBeginningBalance()));
				retMap.put("interest_receivable_ending_balance", format.format(sheetBalance.getInterestReceivableEndingBalance() == null ? 0 : sheetBalance.getInterestReceivableEndingBalance()));
				retMap.put("interest_receivable_beginning_balance", format.format(sheetBalance.getInterestReceivableBeginningBalance() == null ? 0 : sheetBalance.getInterestReceivableBeginningBalance()));
				retMap.put("other_receivables_ending_balance", format.format(sheetBalance.getOtherReceivablesEndingBalance() == null ? 0 : sheetBalance.getOtherReceivablesEndingBalance()));
				retMap.put("other_receivables_beginning_balance", format.format(sheetBalance.getOtherReceivablesBeginningBalance() == null ? 0 : sheetBalance.getOtherReceivablesBeginningBalance()));
				retMap.put("stock_ending_balance", format.format(sheetBalance.getStockEndingBalance() == null ? 0 : sheetBalance.getStockEndingBalance()));
				retMap.put("stock_beginning_balance", format.format(sheetBalance.getStockBeginningBalance() == null ? 0 : sheetBalance.getStockBeginningBalance()));
				retMap.put("stock_raw_materials_ending_balance", format.format(sheetBalance.getStockRawMaterialsEndingBalance() == null ? 0 : sheetBalance.getStockRawMaterialsEndingBalance()));
				retMap.put("stock_raw_materials_beginning_balance", format.format(sheetBalance.getStockRawMaterialsBeginningBalance() == null ? 0 : sheetBalance.getStockRawMaterialsBeginningBalance()));
				retMap.put("stock_product_ending_balance", format.format(sheetBalance.getStockProductEndingBalance() == null ? 0 : sheetBalance.getStockProductEndingBalance()));
				retMap.put("stock_product_beginning_balance", format.format(sheetBalance.getStockProductBeginningBalance() == null ? 0 : sheetBalance.getStockProductBeginningBalance()));
				retMap.put("stock_merchandise_inventory_ending_balance", format.format(sheetBalance.getStockMerchandiseInventoryEndingBalance() == null ? 0 : sheetBalance.getStockMerchandiseInventoryEndingBalance()));
				retMap.put("stock_merchandise_inventory_beginning_balance", format.format(sheetBalance.getStockMerchandiseInventoryBeginningBalance() == null ? 0 : sheetBalance.getStockMerchandiseInventoryBeginningBalance()));
				retMap.put("stock_revolving_materials_ending_balance", format.format(sheetBalance.getStockRevolvingMaterialsEndingBalance() == null ? 0 : sheetBalance.getStockRevolvingMaterialsEndingBalance()));
				retMap.put("stock_revolving_materials_beginning_balance", format.format(sheetBalance.getStockRevolvingMaterialsBeginningBalance() == null ? 0 : sheetBalance.getStockRevolvingMaterialsBeginningBalance()));
				retMap.put("other_current_assets_ending_balance", format.format(sheetBalance.getOtherCurrentAssetsEndingBalance() == null ? 0 : sheetBalance.getOtherCurrentAssetsEndingBalance()));
				retMap.put("other_current_assets_beginning_balance", format.format(sheetBalance.getOtherCurrentAssetsBeginningBalance() == null ? 0 : sheetBalance.getOtherCurrentAssetsBeginningBalance()));
				retMap.put("total_current_assets_ending_balance", format.format(sheetBalance.getTotalCurrentAssetsEndingBalance() == null ? 0 : sheetBalance.getTotalCurrentAssetsEndingBalance()));
				retMap.put("total_current_assets_beginning_balance", format.format(sheetBalance.getTotalCurrentAssetsBeginningBalance() == null ? 0 : sheetBalance.getTotalCurrentAssetsBeginningBalance()));
				retMap.put("long_term_investments_in_bonds_ending_balance", format.format(sheetBalance.getLongTermInvestmentsInBondsEndingBalance() == null ? 0 : sheetBalance.getLongTermInvestmentsInBondsEndingBalance()));
				retMap.put("long_term_investments_in_bonds_beginning_balance", format.format(sheetBalance.getLongTermInvestmentsInBondsBeginningBalance() == null ? 0 : sheetBalance.getLongTermInvestmentsInBondsBeginningBalance()));
				retMap.put("long_term_investment_on_stocks_ending_balance", format.format(sheetBalance.getLongTermInvestmentOnStocksEndingBalance() == null ? 0 : sheetBalance.getLongTermInvestmentOnStocksEndingBalance()));
				retMap.put("long_term_investment_on_stocks_beginning_balance", format.format(sheetBalance.getLongTermInvestmentOnStocksBeginningBalance() == null ? 0 : sheetBalance.getLongTermInvestmentOnStocksBeginningBalance()));
				retMap.put("fixed_assets_original_cost_ending_balance", format.format(sheetBalance.getFixedAssetsOriginalCostEndingBalance() == null ? 0 : sheetBalance.getFixedAssetsOriginalCostEndingBalance()));
				retMap.put("fixed_assets_original_cost_beginning_balance", format.format(sheetBalance.getFixedAssetsOriginalCostBeginningBalance() == null ? 0 : sheetBalance.getFixedAssetsOriginalCostBeginningBalance()));
				retMap.put("accumulated_depreciation_ending_balance", format.format(sheetBalance.getAccumulatedDepreciationEndingBalance() == null ? 0 : sheetBalance.getAccumulatedDepreciationEndingBalance()));
				retMap.put("accumulated_depreciation_beginning_balance", format.format(sheetBalance.getAccumulatedDepreciationBeginningBalance() == null ? 0 : sheetBalance.getAccumulatedDepreciationBeginningBalance()));
				retMap.put("book_value_of_fixed_assets_ending_balance", format.format(sheetBalance.getBookValueOfFixedAssetsEndingBalance() == null ? 0 : sheetBalance.getBookValueOfFixedAssetsEndingBalance()));
				retMap.put("book_value_of_fixed_assets_beginning_balance", format.format(sheetBalance.getBookValueOfFixedAssetsBeginningBalance() == null ? 0 : sheetBalance.getBookValueOfFixedAssetsBeginningBalance()));
				retMap.put("construction_in_process_ending_balance", format.format(sheetBalance.getConstructionInProcessEndingBalance() == null ? 0 : sheetBalance.getConstructionInProcessEndingBalance()));
				retMap.put("construction_in_process_beginning_balance", format.format(sheetBalance.getConstructionInProcessBeginningBalance() == null ? 0 : sheetBalance.getConstructionInProcessBeginningBalance()));
				retMap.put("construction_materials_ending_balance", format.format(sheetBalance.getConstructionMaterialsEndingBalance() == null ? 0 : sheetBalance.getConstructionMaterialsEndingBalance()));
				retMap.put("construction_materials_beginning_balance", format.format(sheetBalance.getConstructionMaterialsBeginningBalance() == null ? 0 : sheetBalance.getConstructionMaterialsBeginningBalance()));
				retMap.put("removal_of_fixed_assets_ending_balance", format.format(sheetBalance.getRemovalOfFixedAssetsEndingBalance() == null ? 0 : sheetBalance.getRemovalOfFixedAssetsEndingBalance()));
				retMap.put("removal_of_fixed_assets_beginning_balance", format.format(sheetBalance.getRemovalOfFixedAssetsBeginningBalance() == null ? 0 : sheetBalance.getRemovalOfFixedAssetsBeginningBalance()));
				retMap.put("biological_assets_ending_balance", format.format(sheetBalance.getBiologicalAssetsEndingBalance() == null ? 0 : sheetBalance.getBiologicalAssetsEndingBalance()));
				retMap.put("biological_assets_beginning_balance", format.format(sheetBalance.getBiologicalAssetsBeginningBalance() == null ? 0 : sheetBalance.getBiologicalAssetsBeginningBalance()));
				retMap.put("intangible_assets_ending_balance", format.format(sheetBalance.getIntangibleAssetsEndingBalance() == null ? 0 : sheetBalance.getIntangibleAssetsEndingBalance()));
				retMap.put("intangible_assets_beginning_balance", format.format(sheetBalance.getIntangibleAssetsBeginningBalance() == null ? 0 : sheetBalance.getIntangibleAssetsBeginningBalance()));
				retMap.put("development_expenditure_ending_balance", format.format(sheetBalance.getDevelopmentExpenditureEndingBalance() == null ? 0 : sheetBalance.getDevelopmentExpenditureEndingBalance()));
				retMap.put("development_expenditure_beginning_balance", format.format(sheetBalance.getDevelopmentExpenditureBeginningBalance() == null ? 0 : sheetBalance.getDevelopmentExpenditureBeginningBalance()));
				retMap.put("long_term_prepaid_expenses_ending_balance", format.format(sheetBalance.getLongTermPrepaidExpensesEndingBalance() == null ? 0 : sheetBalance.getLongTermPrepaidExpensesEndingBalance()));
				retMap.put("long_term_prepaid_expenses_beginning_balance", format.format(sheetBalance.getLongTermPrepaidExpensesBeginningBalance() == null ? 0 : sheetBalance.getLongTermPrepaidExpensesBeginningBalance()));
				retMap.put("other_non_current_assets_ending_balance", format.format(sheetBalance.getOtherNonCurrentAssetsEndingBalance() == null ? 0 : sheetBalance.getOtherNonCurrentAssetsEndingBalance()));
				retMap.put("other_non_current_assets_beginning_balance", format.format(sheetBalance.getOtherNonCurrentAssetsBeginningBalance() == null ? 0 : sheetBalance.getOtherNonCurrentAssetsBeginningBalance()));
				retMap.put("total_non_current_assets_ending_balance", format.format(sheetBalance.getTotalNonCurrentAssetsEndingBalance() == null ? 0 : sheetBalance.getTotalNonCurrentAssetsEndingBalance()));
				retMap.put("total_non_current_assets_beginning_balance", format.format(sheetBalance.getTotalNonCurrentAssetsBeginningBalance() == null ? 0 : sheetBalance.getTotalNonCurrentAssetsBeginningBalance()));
				retMap.put("total_assets_ending_balance", format.format(sheetBalance.getTotalAssetsEndingBalance() == null ? 0 : sheetBalance.getTotalAssetsEndingBalance()));
				retMap.put("total_assets_beginning_balance", format.format(sheetBalance.getTotalAssetsBeginningBalance() == null ? 0 : sheetBalance.getTotalAssetsBeginningBalance()));
				retMap.put("short_loan_ending_balance", format.format(sheetBalance.getShortLoanEndingBalance() == null ? 0 : sheetBalance.getShortLoanEndingBalance()));
				retMap.put("short_loan_beginning_balance", format.format(sheetBalance.getShortLoanBeginningBalance() == null ? 0 : sheetBalance.getShortLoanBeginningBalance()));
				retMap.put("notes_payable_ending_balance", format.format(sheetBalance.getNotesPayableEndingBalance() == null ? 0 : sheetBalance.getNotesPayableEndingBalance()));
				retMap.put("notes_payable_beginning_balance", format.format(sheetBalance.getNotesPayableBeginningBalance() == null ? 0 : sheetBalance.getNotesPayableBeginningBalance()));
				retMap.put("payable_account_ending_balance", format.format(sheetBalance.getPayableAccountEndingBalance() == null ? 0 : sheetBalance.getPayableAccountEndingBalance()));
				retMap.put("payable_account_beginning_balance", format.format(sheetBalance.getPayableAccountBeginningBalance() == null ? 0 : sheetBalance.getPayableAccountBeginningBalance()));
				retMap.put("deposit_received_ending_balance", format.format(sheetBalance.getDepositReceivedEndingBalance() == null ? 0 : sheetBalance.getDepositReceivedEndingBalance()));
				retMap.put("deposit_received_beginning_balance", format.format(sheetBalance.getDepositReceivedBeginningBalance() == null ? 0 : sheetBalance.getDepositReceivedBeginningBalance()));
				retMap.put("employee_benefits_payable_ending_balance", format.format(sheetBalance.getEmployeeBenefitsPayableEndingBalance() == null ? 0 : sheetBalance.getEmployeeBenefitsPayableEndingBalance()));
				retMap.put("employee_benefits_payable_beginning_balance", format.format(sheetBalance.getEmployeeBenefitsPayableBeginningBalance() == null ? 0 : sheetBalance.getEmployeeBenefitsPayableBeginningBalance()));
				retMap.put("taxes_payable_ending_balance", format.format(sheetBalance.getTaxesPayableEndingBalance() == null ? 0 : sheetBalance.getTaxesPayableEndingBalance()));
				retMap.put("taxes_payable_beginning_balance", format.format(sheetBalance.getTaxesPayableBeginningBalance() == null ? 0 : sheetBalance.getTaxesPayableBeginningBalance()));
				retMap.put("interest_payable_ending_balance", format.format(sheetBalance.getInterestPayableEndingBalance() == null ? 0 : sheetBalance.getInterestPayableEndingBalance()));
				retMap.put("interest_payable_beginning_balance", format.format(sheetBalance.getInterestPayableBeginningBalance() == null ? 0 : sheetBalance.getInterestPayableBeginningBalance()));
				retMap.put("profit_payable_ending_balance", format.format(sheetBalance.getProfitPayableEndingBalance() == null ? 0 : sheetBalance.getProfitPayableEndingBalance()));
				retMap.put("profit_payable_beginning_balance", format.format(sheetBalance.getProfitPayableBeginningBalance() == null ? 0 : sheetBalance.getProfitPayableBeginningBalance()));
				retMap.put("accounts_payable_others_ending_balance", format.format(sheetBalance.getAccountsPayableOthersEndingBalance() == null ? 0 : sheetBalance.getAccountsPayableOthersEndingBalance()));
				retMap.put("accounts_payable_others_beginning_balance", format.format(sheetBalance.getAccountsPayableOthersBeginningBalance() == null ? 0 : sheetBalance.getAccountsPayableOthersBeginningBalance()));
				retMap.put("other_current_liabilities_ending_balance", format.format(sheetBalance.getOtherCurrentLiabilitiesEndingBalance() == null ? 0 : sheetBalance.getOtherCurrentLiabilitiesEndingBalance()));
				retMap.put("other_current_liabilities_beginning_balance", format.format(sheetBalance.getOtherCurrentLiabilitiesBeginningBalance() == null ? 0 : sheetBalance.getOtherCurrentLiabilitiesBeginningBalance()));
				retMap.put("total_current_liabilities_ending_balance", format.format(sheetBalance.getTotalCurrentLiabilitiesEndingBalance() == null ? 0 : sheetBalance.getTotalCurrentLiabilitiesEndingBalance()));
				retMap.put("total_current_liabilities_beginning_balance", format.format(sheetBalance.getTotalCurrentLiabilitiesBeginningBalance() == null ? 0 : sheetBalance.getTotalCurrentLiabilitiesBeginningBalance()));
				retMap.put("long_loan_ending_balance", format.format(sheetBalance.getLongLoanEndingBalance() == null ? 0 : sheetBalance.getLongLoanEndingBalance()));
				retMap.put("long_loan_beginning_balance", format.format(sheetBalance.getLongLoanBeginningBalance() == null ? 0 : sheetBalance.getLongLoanBeginningBalance()));
				retMap.put("long_term_payables_ending_balance", format.format(sheetBalance.getLongTermPayablesEndingBalance() == null ? 0 : sheetBalance.getLongTermPayablesEndingBalance()));
				retMap.put("long_term_payables_beginning_balance", format.format(sheetBalance.getLongTermPayablesBeginningBalance() == null ? 0 : sheetBalance.getLongTermPayablesBeginningBalance()));
				retMap.put("deferred_income_ending_balance", format.format(sheetBalance.getDeferredIncomeEndingBalance() == null ? 0 : sheetBalance.getDeferredIncomeEndingBalance()));
				retMap.put("deferred_income_beginning_balance", format.format(sheetBalance.getDeferredIncomeBeginningBalance() == null ? 0 : sheetBalance.getDeferredIncomeBeginningBalance()));
				retMap.put("other_non_current_liabilities_ending_balance", format.format(sheetBalance.getOtherNonCurrentLiabilitiesEndingBalance() == null ? 0 : sheetBalance.getOtherNonCurrentLiabilitiesEndingBalance()));
				retMap.put("other_non_current_liabilities_beginning_balance", format.format(sheetBalance.getOtherNonCurrentLiabilitiesBeginningBalance() == null ? 0 : sheetBalance.getOtherNonCurrentLiabilitiesBeginningBalance()));
				retMap.put("total_non_current_liabilities_ending_balance", format.format(sheetBalance.getTotalNonCurrentLiabilitiesEndingBalance() == null ? 0 : sheetBalance.getTotalNonCurrentLiabilitiesEndingBalance()));
				retMap.put("total_non_current_liabilities_beginning_balance", format.format(sheetBalance.getTotalNonCurrentLiabilitiesBeginningBalance() == null ? 0 : sheetBalance.getTotalNonCurrentLiabilitiesBeginningBalance()));
				retMap.put("total_liabilities_ending_balance", format.format(sheetBalance.getTotalLiabilitiesEndingBalance() == null ? 0 : sheetBalance.getTotalLiabilitiesEndingBalance()));
				retMap.put("total_liabilities_beginning_balance", format.format(sheetBalance.getTotalLiabilitiesBeginningBalance() == null ? 0 : sheetBalance.getTotalLiabilitiesBeginningBalance()));
				retMap.put("paid_in_capital_ending_balance", format.format(sheetBalance.getPaidInCapitalEndingBalance() == null ? 0 : sheetBalance.getPaidInCapitalEndingBalance()));
				retMap.put("paid_in_capital_beginning_balance", format.format(sheetBalance.getPaidInCapitalBeginningBalance() == null ? 0 : sheetBalance.getPaidInCapitalBeginningBalance()));
				retMap.put("capital_reserve_ending_balance", format.format(sheetBalance.getCapitalReserveEndingBalance() == null ? 0 : sheetBalance.getCapitalReserveEndingBalance()));
				retMap.put("capital_reserve_beginning_balance", format.format(sheetBalance.getCapitalReserveBeginningBalance() == null ? 0 : sheetBalance.getCapitalReserveBeginningBalance()));
				retMap.put("earned_surplus_ending_balance", format.format(sheetBalance.getEarnedSurplusEndingBalance() == null ? 0 : sheetBalance.getEarnedSurplusEndingBalance()));
				retMap.put("earned_surplus_beginning_balance", format.format(sheetBalance.getEarnedSurplusBeginningBalance() == null ? 0 : sheetBalance.getEarnedSurplusBeginningBalance()));
				retMap.put("undistributed_profit_ending_balance", format.format(sheetBalance.getUndistributedProfitEndingBalance() == null ? 0 : sheetBalance.getUndistributedProfitEndingBalance()));
				retMap.put("undistributed_profit_beginning_balance", format.format(sheetBalance.getUndistributedProfitBeginningBalance() == null ? 0 : sheetBalance.getUndistributedProfitBeginningBalance()));
				retMap.put("total_equities_ending_balance", format.format(sheetBalance.getTotalEquitiesEndingBalance() == null ? 0 : sheetBalance.getTotalEquitiesEndingBalance()));
				retMap.put("total_equities_beginning_balance", format.format(sheetBalance.getTotalEquitiesBeginningBalance() == null ? 0 : sheetBalance.getTotalEquitiesBeginningBalance()));
				retMap.put("total_liabilities_and_owner_equity_ending_balance", format.format(sheetBalance.getTotalLiabilitiesAndOwnerEquityEndingBalance() == null ? 0 : sheetBalance.getTotalLiabilitiesAndOwnerEquityEndingBalance()));
				retMap.put("total_liabilities_and_owner_equity_beginning_balance", format.format(sheetBalance.getTotalLiabilitiesAndOwnerEquityBeginningBalance() == null ? 0 : sheetBalance.getTotalLiabilitiesAndOwnerEquityBeginningBalance()));
			} else {
				retMap.put("result_is_null", "true");
			}
			break;
		case "利润表":
			SheetIncome sheetIncome = sheetDao.getSheetIncome(companyId, billDate);
			if(sheetIncome != null) {
				retMap.put("result_is_null", "false");
				retMap.put("type", 2);
				DecimalFormat format = new DecimalFormat("#0.000");
				retMap.put("preparedby", sheetIncome.getPreparedby());
				retMap.put("company_controller", sheetIncome.getCompanyController());
				retMap.put("finance_chief", sheetIncome.getFinanceChief());
				retMap.put("tabulator", sheetIncome.getTabulator());
				retMap.put("create_time", sheetIncome.getCreateTime());
				retMap.put("operating_receipt_year", format.format(sheetIncome.getOperatingReceiptYear() == null ? 0 : sheetIncome.getOperatingReceiptYear()));
				retMap.put("operating_receipt_month", format.format(sheetIncome.getOperatingReceiptMonth() == null ? 0 : sheetIncome.getOperatingReceiptMonth()));
				retMap.put("cost_in_business_year", format.format(sheetIncome.getCostInBusinessYear() == null ? 0 : sheetIncome.getCostInBusinessYear()));
				retMap.put("cost_in_business_month", format.format(sheetIncome.getCostInBusinessMonth() == null ? 0 : sheetIncome.getCostInBusinessMonth()));
				retMap.put("business_tariff_and_annex_year", format.format(sheetIncome.getBusinessTariffAndAnnexYear() == null ? 0 : sheetIncome.getBusinessTariffAndAnnexYear()));
				retMap.put("business_tariff_and_annex_month", format.format(sheetIncome.getBusinessTariffAndAnnexMonth() == null ? 0 : sheetIncome.getBusinessTariffAndAnnexMonth()));
				retMap.put("excise_tax_year", format.format(sheetIncome.getExciseTaxYear() == null ? 0 : sheetIncome.getExciseTaxYear()));
				retMap.put("excise_tax_month", format.format(sheetIncome.getExciseTaxMonth() == null ? 0 : sheetIncome.getExciseTaxMonth()));
				retMap.put("sales_tax_year", format.format(sheetIncome.getSalesTaxYear() == null ? 0 : sheetIncome.getSalesTaxYear()));
				retMap.put("sales_tax_month", format.format(sheetIncome.getSalesTaxMonth() == null ? 0 : sheetIncome.getSalesTaxMonth()));
				retMap.put("urban_maintenance_and_construction_tax_year", format.format(sheetIncome.getUrbanMaintenanceAndConstructionTaxYear() == null ? 0 : sheetIncome.getUrbanMaintenanceAndConstructionTaxYear()));
				retMap.put("urban_maintenance_and_construction_month", format.format(sheetIncome.getUrbanMaintenanceAndConstructionMonth() == null ? 0 : sheetIncome.getUrbanMaintenanceAndConstructionMonth()));
				retMap.put("resource_tax_year", format.format(sheetIncome.getResourceTaxYear() == null ? 0 : sheetIncome.getResourceTaxYear()));
				retMap.put("resource_tax_month", format.format(sheetIncome.getResourceTaxMonth() == null ? 0 : sheetIncome.getResourceTaxMonth()));
				retMap.put("land_value_increment_tax_year", format.format(sheetIncome.getLandValueIncrementTaxYear() == null ? 0 : sheetIncome.getLandValueIncrementTaxYear()));
				retMap.put("land_value_increment_tax_month", format.format(sheetIncome.getLandValueIncrementTaxMonth() == null ? 0 : sheetIncome.getLandValueIncrementTaxMonth()));
				retMap.put("land_house_tax_year", format.format(sheetIncome.getLandHouseTaxYear() == null ? 0 : sheetIncome.getLandHouseTaxYear()));
				retMap.put("land_house_tax_month", format.format(sheetIncome.getLandHouseTaxMonth() == null ? 0 : sheetIncome.getLandHouseTaxMonth()));
				retMap.put("education_year", format.format(sheetIncome.getEducationYear() == null ? 0 : sheetIncome.getEducationYear()));
				retMap.put("education_month", format.format(sheetIncome.getEducationMonth() == null ? 0 : sheetIncome.getEducationMonth()));
				retMap.put("sales_year", format.format(sheetIncome.getSalesYear() == null ? 0 : sheetIncome.getSalesYear()));
				retMap.put("sales_month", format.format(sheetIncome.getSalesMonth() == null ? 0 : sheetIncome.getSalesMonth()));
				retMap.put("maintenance_year", format.format(sheetIncome.getMaintenanceYear() == null ? 0 : sheetIncome.getMaintenanceYear()));
				retMap.put("maintenance_month", format.format(sheetIncome.getMaintenanceMonth() == null ? 0 : sheetIncome.getMaintenanceMonth()));
				retMap.put("advertise_year", format.format(sheetIncome.getAdvertiseYear() == null ? 0 : sheetIncome.getAdvertiseYear()));
				retMap.put("advertise_month", format.format(sheetIncome.getAdvertiseMonth() == null ? 0 : sheetIncome.getAdvertiseMonth()));
				retMap.put("manage_year", format.format(sheetIncome.getManageYear() == null ? 0 : sheetIncome.getManageYear()));
				retMap.put("manage_month", format.format(sheetIncome.getManageMonth() == null ? 0 : sheetIncome.getManageMonth()));
				retMap.put("establishment_charges_year", format.format(sheetIncome.getEstablishmentChargesYear() == null ? 0 : sheetIncome.getEstablishmentChargesYear()));
				retMap.put("establishment_charges_month", format.format(sheetIncome.getEstablishmentChargesMonth() == null ? 0 : sheetIncome.getEstablishmentChargesMonth()));
				retMap.put("business_entertainment_year", format.format(sheetIncome.getBusinessEntertainmentYear() == null ? 0 : sheetIncome.getBusinessEntertainmentYear()));
				retMap.put("business_entertainment_month", format.format(sheetIncome.getBusinessEntertainmentMonth() == null ? 0 : sheetIncome.getBusinessEntertainmentMonth()));
				retMap.put("research_year", format.format(sheetIncome.getResearchYear() == null ? 0 : sheetIncome.getResearchYear()));
				retMap.put("research_month", format.format(sheetIncome.getResearchMonth() == null ? 0 : sheetIncome.getResearchMonth()));
				retMap.put("finance_year", format.format(sheetIncome.getFinanceYear() == null ? 0 : sheetIncome.getFinanceYear()));
				retMap.put("finance_month", format.format(sheetIncome.getFinanceMonth() == null ? 0 : sheetIncome.getFinanceMonth()));
				retMap.put("interest_year", format.format(sheetIncome.getInterestYear() == null ? 0 : sheetIncome.getInterestYear()));
				retMap.put("interest_month", format.format(sheetIncome.getInterestMonth() == null ? 0 : sheetIncome.getInterestMonth()));
				retMap.put("equity_earnings_year", format.format(sheetIncome.getEquityEarningsYear() == null ? 0 : sheetIncome.getEquityEarningsYear()));
				retMap.put("equity_earnings_month", format.format(sheetIncome.getEquityEarningsMonth() == null ? 0 : sheetIncome.getEquityEarningsMonth()));
				retMap.put("operating_profit_year", format.format(sheetIncome.getOperatingProfitYear() == null ? 0 : sheetIncome.getOperatingProfitYear()));
				retMap.put("operating_profit_month", format.format(sheetIncome.getOperatingProfitMonth() == null ? 0 : sheetIncome.getOperatingProfitMonth()));
				retMap.put("nonbusiness_income_year", format.format(sheetIncome.getNonbusinessIncomeYear() == null ? 0 : sheetIncome.getNonbusinessIncomeYear()));
				retMap.put("nonbusiness_income_month", format.format(sheetIncome.getNonbusinessIncomeMonth() == null ? 0 : sheetIncome.getNonbusinessIncomeMonth()));
				retMap.put("government_grants_year", format.format(sheetIncome.getGovernmentGrantsYear() == null ? 0 : sheetIncome.getGovernmentGrantsYear()));
				retMap.put("government_grants_month", format.format(sheetIncome.getGovernmentGrantsMonth() == null ? 0 : sheetIncome.getGovernmentGrantsMonth()));
				retMap.put("non_business_expenditure_year", format.format(sheetIncome.getNonBusinessExpenditureYear() == null ? 0 : sheetIncome.getNonBusinessExpenditureYear()));
				retMap.put("non_business_expenditure_month", format.format(sheetIncome.getNonBusinessExpenditureMonth() == null ? 0 : sheetIncome.getNonBusinessExpenditureMonth()));
				retMap.put("loss_on_bad_debt_year", format.format(sheetIncome.getLossOnBadDebtYear() == null ? 0 : sheetIncome.getLossOnBadDebtYear()));
				retMap.put("loss_on_bad_debt_month", format.format(sheetIncome.getLossOnBadDebtMonth() == null ? 0 : sheetIncome.getLossOnBadDebtMonth()));
				retMap.put("loss_on_long_term_bonds_year", format.format(sheetIncome.getLossOnLongTermBondsYear() == null ? 0 : sheetIncome.getLossOnLongTermBondsYear()));
				retMap.put("loss_on_long_term_bonds_month", format.format(sheetIncome.getLossOnLongTermBondsMonth() == null ? 0 : sheetIncome.getLossOnLongTermBondsMonth()));
				retMap.put("loss_on_long_term_stock_year", format.format(sheetIncome.getLossOnLongTermStockYear() == null ? 0 : sheetIncome.getLossOnLongTermStockYear()));
				retMap.put("loss_on_long_term_stock_month", format.format(sheetIncome.getLossOnLongTermStockMonth() == null ? 0 : sheetIncome.getLossOnLongTermStockMonth()));
				retMap.put("loss_on_long_term_natural_calamities_year", format.format(sheetIncome.getLossOnLongTermNaturalCalamitiesYear() == null ? 0 : sheetIncome.getLossOnLongTermNaturalCalamitiesYear()));
				retMap.put("loss_on_long_term_natural_calamities_month", format.format(sheetIncome.getLossOnLongTermNaturalCalamitiesMonth() == null ? 0 : sheetIncome.getLossOnLongTermNaturalCalamitiesMonth()));
				retMap.put("tax_delay_charge_year", format.format(sheetIncome.getTaxDelayChargeYear() == null ? 0 : sheetIncome.getTaxDelayChargeYear()));
				retMap.put("tax_delay_charge_month", format.format(sheetIncome.getTaxDelayChargeMonth() == null ? 0 : sheetIncome.getTaxDelayChargeMonth()));
				retMap.put("total_profit_year", format.format(sheetIncome.getTotalProfitYear() == null ? 0 : sheetIncome.getTotalProfitYear()));
				retMap.put("total_profit_month", format.format(sheetIncome.getTotalProfitMonth() == null ? 0 : sheetIncome.getTotalProfitMonth()));
				retMap.put("income_tax_expense_year", format.format(sheetIncome.getIncomeTaxExpenseYear() == null ? 0 : sheetIncome.getIncomeTaxExpenseYear()));
				retMap.put("income_tax_expense_month", format.format(sheetIncome.getIncomeTaxExpenseMonth() == null ? 0 : sheetIncome.getIncomeTaxExpenseMonth()));
				retMap.put("net_margin_year", format.format(sheetIncome.getNetMarginYear() == null ? 0 : sheetIncome.getNetMarginYear()));
				retMap.put("net_margin_month", format.format(sheetIncome.getNetMarginMonth() == null ? 0 : sheetIncome.getNetMarginMonth()));
			} else {
				retMap.put("result_is_null", "true");
			}
			break;
		case "现金流量表":
			SheetCash sheetCash = sheetDao.getSheetCash(companyId, billDate);
			if(sheetCash != null) {
				retMap.put("result_is_null", "false");
				retMap.put("type", 3);
				DecimalFormat format = new DecimalFormat("#0.000");
				retMap.put("preparedby", sheetCash.getPreparedby());
				retMap.put("company_controller", sheetCash.getCompanyController());
				retMap.put("finance_chief", sheetCash.getFinanceChief());
				retMap.put("tabulator", sheetCash.getTabulator());
				retMap.put("create_time", sheetCash.getCreateTime());
				retMap.put("sales_year", format.format(sheetCash.getSalesYear() == null ? 0 : sheetCash.getSalesYear()));
				retMap.put("sales_month", format.format(sheetCash.getSalesMonth() == null ? 0 : sheetCash.getSalesMonth()));
				retMap.put("receive_year", format.format(sheetCash.getReceiveYear() == null ? 0 : sheetCash.getReceiveYear()));
				retMap.put("receive_month", format.format(sheetCash.getReceiveMonth() == null ? 0 : sheetCash.getReceiveMonth()));
				retMap.put("buy_year", format.format(sheetCash.getBuyYear() == null ? 0 : sheetCash.getBuyYear()));
				retMap.put("buy_month", format.format(sheetCash.getBuyMonth() == null ? 0 : sheetCash.getBuyMonth()));
				retMap.put("salary_year", format.format(sheetCash.getSalaryYear() == null ? 0 : sheetCash.getSalaryYear()));
				retMap.put("salary_month", format.format(sheetCash.getSalaryMonth() == null ? 0 : sheetCash.getSalaryMonth()));
				retMap.put("tax_year", format.format(sheetCash.getTaxYear() == null ? 0 : sheetCash.getTaxYear()));
				retMap.put("tax_month", format.format(sheetCash.getTaxMonth() == null ? 0 : sheetCash.getTaxMonth()));
				retMap.put("other_pay_year", format.format(sheetCash.getOtherPayYear() == null ? 0 : sheetCash.getOtherPayYear()));
				retMap.put("other_pay_month", format.format(sheetCash.getOtherPayMonth() == null ? 0 : sheetCash.getOtherPayMonth()));
				retMap.put("operating_activities_year", format.format(sheetCash.getOperatingActivitiesYear() == null ? 0 : sheetCash.getOperatingActivitiesYear()));
				retMap.put("operating_activities_month", format.format(sheetCash.getOperatingActivitiesMonth() == null ? 0 : sheetCash.getOperatingActivitiesMonth()));
				retMap.put("take_back_year", format.format(sheetCash.getTakeBackYear() == null ? 0 : sheetCash.getTakeBackYear()));
				retMap.put("take_back_month", format.format(sheetCash.getTakeBackMonth() == null ? 0 : sheetCash.getTakeBackMonth()));
				retMap.put("equity_earnings_year", format.format(sheetCash.getEquityEarningsYear() == null ? 0 : sheetCash.getEquityEarningsYear()));
				retMap.put("equity_earnings_month", format.format(sheetCash.getEquityEarningsMonth() == null ? 0 : sheetCash.getEquityEarningsMonth()));
				retMap.put("handle_year", format.format(sheetCash.getHandleYear() == null ? 0 : sheetCash.getHandleYear()));
				retMap.put("handle_month", format.format(sheetCash.getHandleMonth() == null ? 0 : sheetCash.getHandleMonth()));
				retMap.put("investments_pay_year", format.format(sheetCash.getInvestmentsPayYear() == null ? 0 : sheetCash.getInvestmentsPayYear()));
				retMap.put("investments_pay_month", format.format(sheetCash.getInvestmentsPayMonth() == null ? 0 : sheetCash.getInvestmentsPayMonth()));
				retMap.put("coustruction_year", format.format(sheetCash.getCoustructionYear() == null ? 0 : sheetCash.getCoustructionYear()));
				retMap.put("coustruction_month", format.format(sheetCash.getCoustructionMonth() == null ? 0 : sheetCash.getCoustructionMonth()));
				retMap.put("activity_investment_year", format.format(sheetCash.getActivityInvestmentYear() == null ? 0 : sheetCash.getActivityInvestmentYear()));
				retMap.put("activity_investment_month", format.format(sheetCash.getActivityInvestmentMonth() == null ? 0 : sheetCash.getActivityInvestmentMonth()));
				retMap.put("loan_year", format.format(sheetCash.getLoanYear() == null ? 0 : sheetCash.getLoanYear()));
				retMap.put("loan_month", format.format(sheetCash.getLoanMonth() == null ? 0 : sheetCash.getLoanMonth()));
				retMap.put("investors_to_invest_year", format.format(sheetCash.getInvestorsToInvestYear() == null ? 0 : sheetCash.getInvestorsToInvestYear()));
				retMap.put("investors_to_invest_month", format.format(sheetCash.getInvestorsToInvestMonth() == null ? 0 : sheetCash.getInvestorsToInvestMonth()));
				retMap.put("payment_of_principal_year", format.format(sheetCash.getPaymentOfPrincipalYear() == null ? 0 : sheetCash.getPaymentOfPrincipalYear()));
				retMap.put("payment_of_principal_month", format.format(sheetCash.getPaymentOfPrincipalMonth() == null ? 0 : sheetCash.getPaymentOfPrincipalMonth()));
				retMap.put("paid_interest_year", format.format(sheetCash.getPaidInterestYear() == null ? 0 : sheetCash.getPaidInterestYear()));
				retMap.put("paid_interest_month", format.format(sheetCash.getPaidInterestMonth() == null ? 0 : sheetCash.getPaidInterestMonth()));
				retMap.put("distribute_profit_year", format.format(sheetCash.getDistributeProfitYear() == null ? 0 : sheetCash.getDistributeProfitYear()));
				retMap.put("distribute_profit_month", format.format(sheetCash.getDistributeProfitMonth() == null ? 0 : sheetCash.getDistributeProfitMonth()));
				retMap.put("financing_activity_year", format.format(sheetCash.getFinancingActivityYear() == null ? 0 : sheetCash.getFinancingActivityYear()));
				retMap.put("financing_activity_month", format.format(sheetCash.getFinancingActivityMonth() == null ? 0 : sheetCash.getFinancingActivityMonth()));
				retMap.put("net_increase_in_cash_year", format.format(sheetCash.getNetIncreaseInCashYear() == null ? 0 : sheetCash.getNetIncreaseInCashYear()));
				retMap.put("net_increase_in_cash_month", format.format(sheetCash.getNetIncreaseInCashMonth() == null ? 0 : sheetCash.getNetIncreaseInCashMonth()));
				retMap.put("cash_at_beginning_of_period_year", format.format(sheetCash.getCashAtBeginningOfPeriodYear() == null ? 0 : sheetCash.getCashAtBeginningOfPeriodYear()));
				retMap.put("cash_at_beginning_of_period_month", format.format(sheetCash.getCashAtBeginningOfPeriodMonth() == null ? 0 : sheetCash.getCashAtBeginningOfPeriodMonth()));
				retMap.put("ending_cash_balance_year", format.format(sheetCash.getEndingCashBalanceYear() == null ? 0 : sheetCash.getEndingCashBalanceYear()));
				retMap.put("ending_cash_balance_month", format.format(sheetCash.getEndingCashBalanceMonth() == null ? 0 : sheetCash.getEndingCashBalanceMonth()));
			} else {
				retMap.put("result_is_null", "true");
			}
			break;
		}
		return retMap;
	}

}
